import {
  UPDATE_RECOMMEND_LIST,
  RecommendProductsListActionType,
  UPDATE_RECOMMEND_LOADING,
} from "@/store/recommendProducts/actions";
interface recommendProductsType {
  recommendList: any[];
  loading: boolean;
  error: string | null;
}
const defaultState: recommendProductsType = {
  recommendList: [],
  loading: true,
  error: null,
};
const reducer = (
  state = defaultState,
  action: RecommendProductsListActionType,
) => {
  switch (action.type) {
    case UPDATE_RECOMMEND_LIST:
      return { ...state, loading: true, recommendList: action.recommendList };
    case UPDATE_RECOMMEND_LOADING:
      return {
        ...state,
        loading: action.loading,
        recommendList: [...state.recommendList],
      };
    default:
      return state;
  }
};
export default reducer;
